﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
using System.Data.SqlClient;
using System.Text.RegularExpressions;

namespace dataTOdedecms
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private string getunixtime(DateTime time)
        {
            DateTime dtStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
            DateTime dtNow = time;
            TimeSpan toNow = dtNow.Subtract(dtStart);
            string timeStamp = toNow.Ticks.ToString();
            timeStamp = timeStamp.Substring(0, timeStamp.Length - 7);
            return timeStamp;
        }
        public string NoHTML(string Htmlstring) //去除HTML标记
        {
            //删除脚本
            Htmlstring = Regex.Replace(Htmlstring, @"<script[^>]*?>.*?</script>", "", RegexOptions.IgnoreCase);
            //删除HTML
            Htmlstring = Regex.Replace(Htmlstring, @"<(.[^>]*)>", "", RegexOptions.IgnoreCase);
            Htmlstring = Regex.Replace(Htmlstring, @"([\r\n])[\s]+", "", RegexOptions.IgnoreCase);
            Htmlstring = Regex.Replace(Htmlstring, @"-->", "", RegexOptions.IgnoreCase);
            Htmlstring = Regex.Replace(Htmlstring, @"<!--.*", "", RegexOptions.IgnoreCase);
            Htmlstring = Regex.Replace(Htmlstring, @"&(quot|#34);", "\"", RegexOptions.IgnoreCase);
            Htmlstring = Regex.Replace(Htmlstring, @"&(amp|#38);", "&", RegexOptions.IgnoreCase);
            Htmlstring = Regex.Replace(Htmlstring, @"&(lt|#60);", "<", RegexOptions.IgnoreCase);
            Htmlstring = Regex.Replace(Htmlstring, @"&(gt|#62);", ">", RegexOptions.IgnoreCase);
            Htmlstring = Regex.Replace(Htmlstring, @"&(nbsp|#160);", " ", RegexOptions.IgnoreCase);
            Htmlstring = Regex.Replace(Htmlstring, @"&(iexcl|#161);", "\xa1", RegexOptions.IgnoreCase);
            Htmlstring = Regex.Replace(Htmlstring, @"&(cent|#162);", "\xa2", RegexOptions.IgnoreCase);
            Htmlstring = Regex.Replace(Htmlstring, @"&(pound|#163);", "\xa3", RegexOptions.IgnoreCase);
            Htmlstring = Regex.Replace(Htmlstring, @"&(copy|#169);", "\xa9", RegexOptions.IgnoreCase);
            Htmlstring = Regex.Replace(Htmlstring, @"&#(\d+);", "", RegexOptions.IgnoreCase);
            Htmlstring.Replace("<", "");
            Htmlstring.Replace(">", "");
            Htmlstring.Replace("\r\n", "");
            //Htmlstring = HttpContext.Current.Server.HtmlEncode(Htmlstring).Trim();
            return Htmlstring;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            string mssqlstr = "Data Source=61.157.152.148;Initial Catalog=dyHouse;UID=dylive;PWD=a1b2c3d4e5";
            
            SqlConnection mssqlcon=new SqlConnection(mssqlstr);
            SqlCommand mssqlcmd = new SqlCommand("select * from h_News order by nSid", mssqlcon);
            SqlDataAdapter mssqlda = new SqlDataAdapter(mssqlcmd);
            DataSet mssqlset=new DataSet();
            mssqlda.Fill(mssqlset);
            //string getid = "select MAX(ID) from dede_archives";
            MySqlConnection mysqlcon = new MySqlConnection("server=127.0.0.1;User Id=root;password=11111111;Persist Security Info=True;database=dedecms2;CharSet=gbk");
            MySqlCommand mysqlcmd = new MySqlCommand("", mysqlcon);
            //mysqlcon.Open();
            //int id = 0;
          

            //id = Convert.ToInt32(mysqlcmd.ExecuteScalar()) + 1;
           
            string insertzhu = "INSERT INTO dede_archives (id,typeid,typeid2,sortrank,flag,ismake,channel,arcrank,click,money,title,shorttitle,color"+
                ",writer,source,litpic,pubdate,senddate,MID,keywords,lastpost,scores,goodpost,badpost,voteid,notpost,description,filename,"+
                "dutyadmin,tackid,mtype,weight) "
            +"VALUES ({0},{1},0,0,'{2}',1,1,0,{10},0,'{3}','','','admin','德阳生活资讯网','{4}',{5},{6},1,'{7}',{8},0,1,2,0,1,'{9}','',1,0,0,0)";
          
            for (int i = 0; i < mssqlset.Tables[0].Rows.Count; i++)
            {
                //id = id + 1;
                //string ids = (id).ToString();//0
                string typeid = "";//1
                string flag = "";//2
                string title = "";//3
                string litpic = "";//4
                string pubdate = "";//5;
                string senddate = "";//6
                string keywords = "";//7
                string lastpost = "";//8
                string description = "";//9
                string click = "0";
                string pianqu = "旌阳区";
                string body = "";
                int oldtype = Convert.ToInt32(mssqlset.Tables[0].Rows[i]["nType"].ToString());
                string oldtitle = mssqlset.Tables[0].Rows[i]["nTitle"].ToString();
                switch (oldtype)
                {
                    case 0:
                        typeid = "16";//全国楼市【楼市热点】、
                        break;
                    case 1:
                        typeid = "17";//政策相关【法律法规】、
                        break;
                    case 2:
                        typeid = "119";//本地新闻【市政建设】、【租售资讯】、
                        if (oldtitle.Contains("一周简报"))
                            typeid = "129";
                        if (oldtitle.Contains("租") || oldtitle.Contains("售"))
                            typeid = "116";
                        break;
                    case 3:
                        typeid = "114";//本地楼市【开盘报道121、楼盘动态114、优惠速递115、项目活动117】、
                        if (oldtitle.Contains("[广汉"))
                            pianqu = "广汉市";
                        if (oldtitle.Contains("[罗江"))
                            pianqu = "罗江县";
                        if (oldtitle.Contains("[中江"))
                            pianqu = "中江县";
                        if (oldtitle.Contains("[什邡"))
                            pianqu = "什邡市";
                        if (oldtitle.Contains("[绵竹"))
                            pianqu = "绵竹市";
                        if (oldtitle.Contains("新项目") || oldtitle.Contains("开盘") || oldtitle.Contains("开售"))
                            typeid = "121";
                        if (oldtitle.Contains("一周简报"))
                            typeid = "129";
                        if (oldtitle.Contains("优惠") || oldtitle.Contains("[特价房]"))
                            typeid = "115";
                        if (oldtitle.Contains("[活动]"))
                            typeid = "117";
                        break;
                    case 4:
                        typeid = "20";//楼市杂谈【楼市杂谈】、
                        break;
                    case 5:
                        typeid = "21";//专家看市【名嘴说市】
                        break;
                    case 6:
                        typeid = "120";//土地政策【土地买卖】、
                        break;
                    case 7:
                        typeid = "18";//购房攻略【置业案例】、【租售资讯19】、【政策解读22】
                        if (oldtitle.Contains("租") || oldtitle.Contains("售"))
                            typeid = "116";
                        if (oldtitle.Contains("解读"))
                            typeid = "22";
                        break;
                    case 8:
                        typeid = "118";//原创统计、施工进度【项目施工】、
                        break;
                    case 9:
                        typeid = "127";//外部统计、NuNu说事专栏【NuNu说事】、
                        break;
                    case 10:
                        typeid = "127";//外部统计、NuNu说事专栏【NuNu说事】、
                        break;
                    case 11:
                        typeid = "126";//验房团专栏【验房团】、
                        break;
                    case 12:
                        typeid = "25";//网站帮助、【今日团购】、【看房计】、【房价走势】、【一周简报】
                        if (oldtitle.Contains("一周简报"))
                            typeid = "129";
                        break;
                    case 13:
                        typeid = "118";//原创统计、施工进度【项目施工】、
                        break;
                    default:
                        MessageBox.Show("未知");
                        break;
                }
                flag = "";
                if (mssqlset.Tables[0].Rows[i]["nMainTitle"].ToString().Trim() != "")
                    title = "[" + mssqlset.Tables[0].Rows[i]["nMainTitle"].ToString() + "]" + oldtitle;
                else
                    title = oldtitle;
                litpic = mssqlset.Tables[0].Rows[i]["nHeadImage"].ToString().Trim();
                body = mssqlset.Tables[0].Rows[i]["nMemo"].ToString().Trim();
                body = body.Replace("'", "\"");
                if (litpic != "")
                {
                    flag = "p";
                }
                DateTime oldtime = Convert.ToDateTime(mssqlset.Tables[0].Rows[i]["nData"]);
               
                pubdate = senddate = lastpost = getunixtime(oldtime);
                keywords = mssqlset.Tables[0].Rows[i]["nKeyword"].ToString().Trim();

                description =NoHTML(body);
                if (description.Length > 200)
                    description = description.Substring(0, 200);
                click = mssqlset.Tables[0].Rows[i]["nCount"].ToString().Trim();
                string ids = getid(typeid, "1", senddate).ToString();
                string cmdstr = string.Format(insertzhu, ids, typeid, flag, title, litpic, pubdate, senddate, keywords, lastpost, description, click);
                string fucmdstr = "INSERT INTO dede_addonarticle (aid,typeid,body,redirecturl,templet,userip,AREA) VALUES({0},{1},'{2}','','','222.214.216.73','{3}')";
                string cmdstr2 = string.Format(fucmdstr, ids, typeid, body, pianqu);
                mysqlcmd.CommandText = cmdstr;
                
                if (mysqlcmd.ExecuteNonQuery() > 0) 
                {
                    mysqlcmd.CommandText = cmdstr2;
                    mysqlcmd.ExecuteNonQuery();
                }
                else
                {
                    MessageBox.Show(ids+"插入错误");
                }
               
               
            } mysqlcon.Close();
        }

        private int getid(string typeid, string channel,string senddate)
        {
            string getid = "INSERT INTO dede_arctiny (typeid,typeid2,arcrank,channel,senddate,sortrank,MID) VALUES("+typeid+",0,0,"+channel+","+senddate+","+senddate+",1)";
            MySqlConnection mysqlcon = new MySqlConnection("server=127.0.0.1;User Id=root;password=11111111;Persist Security Info=True;database=dedecms2;CharSet=gbk");
            MySqlCommand mysqlcmd = new MySqlCommand(getid, mysqlcon);
            mysqlcon.Open();
            if (mysqlcmd.ExecuteNonQuery() > 0)
            {
                getid = "select MAX(ID) from dede_archives";
                 int id=0;
                 id = Convert.ToInt32(mysqlcmd.ExecuteScalar());
                 return id;
            }
            else
            return 0;
        }


        private int insertimgs(string id,string title)
        {
            //string huxinghtml = "<div style='float: left;height:auto;width: 165px;margin-right: 30px;margin-left: 30px; overflow:hidden; display:inline;'><img height='125' width='165' src='{0}'><div style='height:10px;'></div><table width='165' border='0' cellspacing='1' cellpadding='10' bgcolor='#CCCCCC'><tbody><tr><td width='48' bgcolor='#FFFFFF'>建筑面积</td><td width='74' bgcolor='#FFFFFF'>{1}</td></tr><tr><td bgcolor='#FFFFFF'>户型</td><td bgcolor='#FFFFFF'>{2}</td></tr><tr><td bgcolor='#FFFFFF'>户型名</td><td bgcolor='#FFFFFF'>{3}</td></tr></tbody></table></div>";
            string huxing = "";//户型图集ID
            string tmpimg = "";
            string tmpmianji = "";
            string tmphuxing = "";
            string tmpname = "";
            string smallimg = "";//缩略图
            MySqlConnection mysqlcon = new MySqlConnection("server=127.0.0.1;User Id=root;password=11111111;Persist Security Info=True;database=dedecms2;CharSet=gbk");
            MySqlCommand mysqlcmd = new MySqlCommand("", mysqlcon);
            string mssqlstr = "Data Source=61.157.152.148;Initial Catalog=dyHouse;UID=dylive;PWD=a1b2c3d4e5";

            SqlConnection mssqlcon = new SqlConnection(mssqlstr);
            SqlCommand mssqlcmd = new SqlCommand("", mssqlcon);
            mssqlcmd.CommandText = "select * from h_Threshold where tParHouseId=" + id;//户型处理
            //数据插入dede_addonimages表
            /*
            {dede:pagestyle maxwidth='800' pagepicnum='12' ddmaxwidth='200' row='1' col='6' value='3'/}
{dede:img ddimg='/uploads/allimg/120518/1-12051P92401-lp.jpg' text='122.15|三室两厅一卫|9#、10#' width='180' height='130'} /uploads/allimg/120518/1-12051P92401.jpg {/dede:img}
{dede:img ddimg='/uploads/allimg/120518/1-12051P92402-lp.jpg' text='94.15|两室两厅一卫|9#、10#' width='180' height='130'} /uploads/allimg/120518/1-12051P92402.jpg {/dede:img}
{dede:img ddimg='/uploads/allimg/120518/1-12051P92402-50-lp.jpg' text='73.15|一室两厅一卫|9#、10#' width='620' height='410'} /uploads/allimg/120518/1-12051P92402-50.jpg {/dede:img}

             */
            string model = "{dede:img ddimg='{0}' text='{1}' width='200' height='100'} {2} {/dede:img}";
            string imgurlmodel = " {dede:pagestyle maxwidth='800' pagepicnum='12' ddmaxwidth='200' row='1' col='6' value='3'/}";
           
            //插入主键表，获取ID
            int theid = getid("147", "2", getunixtime(DateTime.Now));
            if (theid == 0)
                return 0;
            DataSet huxingset = new DataSet();
          SqlDataAdapter  mssqlda = new SqlDataAdapter(mssqlcmd);
            mssqlda.Fill(huxingset);
            string imgurl = "";
            if (huxingset.Tables[0].Rows.Count > 0)
            {
               
                for (int j = 0; j < huxingset.Tables[0].Rows.Count; j++)
                {
                    tmpimg = huxingset.Tables[0].Rows[j]["tHeadImage"].ToString();//户型图片
                    tmpmianji = huxingset.Tables[0].Rows[j]["tArea"].ToString();//面积
                    tmpname = huxingset.Tables[0].Rows[j]["tTitle"].ToString();//户型名
                    tmphuxing = huxingset.Tables[0].Rows[j]["tSpace"].ToString();//户型
                    smallimg = tmpimg.Replace("/Threshold", "/Threshold/SmallUpload");
                    imgurl = imgurlmodel + string.Format(model, tmpimg, tmpmianji + "|" + tmphuxing + "|" + tmpname,smallimg);
                    switch (tmphuxing)
                    {
                        case "1":
                            tmphuxing = "1室1厅1卫";
                            break;
                        case "3":
                            tmphuxing = "1室2厅1卫";
                            break;
                        case "4":
                            tmphuxing = "2室1厅1卫";
                            break;
                        case "5":
                            tmphuxing = "2室1厅2卫";
                            break;
                        case "6":
                            tmphuxing = "2室2厅1卫";
                            break;
                        case "7":
                            tmphuxing = "2室2厅2卫";
                            break;
                        case "8":
                            tmphuxing = "3室1厅1卫";
                            break;
                        case "9":
                            tmphuxing = "3室1厅2卫";
                            break;
                        case "10":
                            tmphuxing = "3室2厅1卫";
                            break;
                        case "11":
                            tmphuxing = "3室2厅2卫";
                            break;
                        case "15":
                            tmphuxing = "4室2厅1卫";
                            break;
                        case "16":
                            tmphuxing = "4室2厅2卫";
                            break;
                        case "17":
                            tmphuxing = "4室2厅3卫";
                            break;
                        case "18":
                            tmphuxing = "4室3厅3卫";
                            break;
                        case "20":
                            tmphuxing = "5室2厅2卫";
                            break;
                        case "21":
                            tmphuxing = "5室2厅3卫";
                            break;
                        case "22":
                            tmphuxing = "5室2厅4卫";
                            break;
                        case "23":
                            tmphuxing = "5室3厅2卫";
                            break;
                        case "24":
                            tmphuxing = "5室3厅3卫";
                            break;
                        case "25":
                            tmphuxing = "5室3厅4卫";
                            break;
                        case "26":
                            tmphuxing = "6室2厅2卫";
                            break;
                        case "27":
                            tmphuxing = "6室3厅2卫";
                            break;
                        case "28":
                            tmphuxing = "6室3厅3卫";
                            break;
                        case "34":
                            tmphuxing = "跃式";
                            break;
                        case "36":
                            tmphuxing = "其它";
                            break;
                        case "37":
                            tmphuxing = "3室3厅2卫";
                            break;
                        default:
                            tmphuxing = "其它";
                            break;
                    }
                   
                }
            }
            string zhu = "INSERT INTO dede_archives (id,typeid,flag,ismake,channel,title,litpic) VALUES ({0},{1},{2},{3},{4},{5},{6})";
            zhu = string.Format(zhu, theid.ToString(), "147", "p", "1", "2", title, smallimg);
            mysqlcmd.CommandText = zhu;
            mysqlcon.Open();
            if (mysqlcmd.ExecuteNonQuery() > 0)
            {
                string fu = "INSERT INTO  dede_addonimages(aid,typeid,pagestyle,maxwidth,imgurls,ROW,col,isrm,ddmaxwidth,pagepicnum,templet,userip,redirecturl,body) VALUES ({0},147,3,800,'',1,6,1,200,12,'{1}','222.214.216.73','','')";
                fu = string.Format(fu, theid.ToString(), imgurl);
                mysqlcmd.CommandText = fu;
                if (mysqlcmd.ExecuteNonQuery() > 0)
                    return theid;
                else
                    return 0;
            }
            else
            return 0;
        }
        private void button2_Click(object sender, EventArgs e)
        {
       
              string mssqlstr = "Data Source=61.157.152.148;Initial Catalog=dyHouse;UID=dylive;PWD=a1b2c3d4e5";
            
            SqlConnection mssqlcon=new SqlConnection(mssqlstr);
            SqlCommand mssqlcmd = new SqlCommand("select * from h_HouseList order by hLid", mssqlcon);
            SqlDataAdapter mssqlda = new SqlDataAdapter(mssqlcmd);
            DataSet mssqlset=new DataSet();
            mssqlda.Fill(mssqlset);
            //string getid = "select MAX(ID) from dede_archives";
            MySqlConnection mysqlcon = new MySqlConnection("server=127.0.0.1;User Id=root;password=11111111;Persist Security Info=True;database=dedecms2;CharSet=gbk");
            MySqlCommand mysqlcmd = new MySqlCommand("", mysqlcon);
            //mysqlcon.Open();
            //int id=0;
          
                
            //id=Convert.ToInt32( mysqlcmd.ExecuteScalar())+1;
           
            //string insertzhu = "INSERT INTO dede_archives (id,typeid,typeid2,sortrank,flag,ismake,channel,arcrank,click,money,title,shorttitle,color"+
            //    ",writer,source,litpic,pubdate,senddate,MID,keywords,lastpost,scores,goodpost,badpost,voteid,notpost,description,filename,"+
            //    "dutyadmin,tackid,mtype,weight) "
            //+"VALUES ({0},{1},0,0,'{2}',1,7,0,{10},0,'{3}','','','admin','德阳生活资讯网','{4}',{5},{6},1,'{7}',{8},0,1,2,0,1,'{9}','',1,0,0,0)";

            for (int i = 0; i < mssqlset.Tables[0].Rows.Count; i++)
            {
                //id = id + 1;
                //string ids = (id).ToString();//0
                string typeid = "176";//1 楼盘 默认旌阳区
                string flag = "";//2
                string title = mssqlset.Tables[0].Rows[i]["hTitle"].ToString().Trim();//3 楼盘名
                string litpic = mssqlset.Tables[0].Rows[i]["hHeadImage"].ToString().Trim();//4
                if (litpic != "")
                {
                    flag = "p";
                }
                string pubdate = getunixtime(Convert.ToDateTime(mssqlset.Tables[0].Rows[i]["hUpdateTime"]));//5;
                string senddate = getunixtime(Convert.ToDateTime(mssqlset.Tables[0].Rows[i]["hDate"]));//6
                string keywords = "";//7
                string lastpost = pubdate;//8
                string description = mssqlset.Tables[0].Rows[i]["hMemo6"].ToString().Trim();//9
                if (description.Length > 200)
                    description = description.Substring(0, 200);
                string click = mssqlset.Tables[0].Rows[i]["hRefCount"].ToString().Trim();

                string status = mssqlset.Tables[0].Rows[i]["hBuyGrade"].ToString().Trim();//状态
                switch (status)
                {
                    case "0":
                        status = "即将开盘";
                        break;
                    case "1":
                        status = "新开盘";
                        break;
                    case "2":
                        status = "在售";
                        break;
                    case "3":
                        status = "尾盘";
                        break;
                    case "4":
                        status = "售罄";
                        break;
                }
                string lp2 = mssqlset.Tables[0].Rows[i]["hArea"].ToString().Trim();//楼盘地区
                switch (lp2)
                {
                    case "0":
                       // lp2 = "旌阳区";
                        typeid = "176";
                        break;
                    case "1":
                        //lp2 = "绵竹市";
                        typeid = "179";
                        break;
                    case "2":
                       // lp2 = "广汉市";
                        typeid = "177";
                        break;
                    case "3":
                       // lp2 = "什邡市";
                        typeid = "180";
                        break;
                    case "4":
                        //lp2 = "罗江县";
                        typeid = "181";
                        break;
                    case "5":
                       // lp2 = "中江县";
                        typeid = "178";
                        break;
                }
                string address = mssqlset.Tables[0].Rows[i]["hAdress"].ToString().Trim();//楼盘地址
                string type = mssqlset.Tables[0].Rows[i]["hType"].ToString().Trim();//楼盘类型
                type = type.Replace("、", ",").Replace(" ", ",").Replace("，", ",");
                string saleaddress = mssqlset.Tables[0].Rows[i]["hBuyAddress"].ToString().Trim();//售楼地址
                string tel = mssqlset.Tables[0].Rows[i]["hTel"].ToString().Trim();//售楼电话
                string starttime = mssqlset.Tables[0].Rows[i]["ByTime3"].ToString().Trim();//开盘时间
                string complettime = mssqlset.Tables[0].Rows[i]["ByTime4"].ToString().Trim();//交房时间
                string lp9 = "是";//按揭贷款
                string midprice = mssqlset.Tables[0].Rows[i]["hAmoney"].ToString().Trim();//参考均价
                if (midprice == "")
                    midprice = "0";
                string upprice = mssqlset.Tables[0].Rows[i]["hBmoney"].ToString().Trim(); ;//最高价
                string downprice = mssqlset.Tables[0].Rows[i]["hSmoney"].ToString().Trim(); ;//最低价
                string touzhi = mssqlset.Tables[0].Rows[i]["hBinder"].ToString().Trim();//投资商
                string kaifa = mssqlset.Tables[0].Rows[i]["hBinder"].ToString().Trim();//开发商
                string jianzu = mssqlset.Tables[0].Rows[i]["hBinder1"].ToString().Trim();//建筑商
                string design = mssqlset.Tables[0].Rows[i]["hDesgin"].ToString().Trim();//设计单位
                string wuye = mssqlset.Tables[0].Rows[i]["hManage"].ToString().Trim();//物业公司
                string daili = mssqlset.Tables[0].Rows[i]["hDesgin3"].ToString().Trim();//销售代理
                string lp17 = "";//行销策划
                string lp18 = "";//预售证号
                string allarea = mssqlset.Tables[0].Rows[i]["hArea1"].ToString().Trim();//占地面积
                string builderarea = mssqlset.Tables[0].Rows[i]["hArea2"].ToString().Trim();//建筑面积
                string rongji = mssqlset.Tables[0].Rows[i]["hArea3"].ToString().Trim();//容积率
                string lvhua = mssqlset.Tables[0].Rows[i]["hArea4"].ToString().Trim();//绿化率
                if (rongji == "")
                    rongji = "0";
                if (lvhua == "")
                    lvhua = "0";
                string lp23 = "";//周边学校
                string lp24 = "";//周边超市
                string lp25 = "";//公交线路
                string lp26 = "";//周边银行
                string lp27 = "";//医疗配套
                string lp28 = "";//周边餐厅//
                string lp29 = "";//周边健身//
                string lp30 = "";//周边其它
                //获取lifeinfo信息
                string oldid = mssqlset.Tables[0].Rows[i]["hLid"].ToString();
                mssqlcmd.CommandText = "select * from h_LivingInfo where lParHouseId=" + oldid;
               
                DataSet lifeinfoset = new DataSet();
                mssqlda  = new SqlDataAdapter(mssqlcmd);
                mssqlda.Fill(lifeinfoset);
                if (lifeinfoset.Tables[0].Rows.Count > 0)
                {
                    lp23 = lifeinfoset.Tables[0].Rows[0]["lStudent"].ToString();
                    lp24 = lifeinfoset.Tables[0].Rows[0]["lShopping"].ToString();
                    lp27 = lifeinfoset.Tables[0].Rows[0]["lDoctect"].ToString();
                    lp28 = lifeinfoset.Tables[0].Rows[0]["lRadio8"].ToString();
                    if (lp28 == "0")
                        lp28 = "无";
                    else
                        lp28 = "有";
                    lp29 = lifeinfoset.Tables[0].Rows[0]["lRadio1"].ToString();
                    if (lp29 == "0")
                        lp29 = "无";
                    else
                        lp29 = "有";
                    lp30 = lifeinfoset.Tables[0].Rows[0]["lPlay"].ToString();
                }
             //获取交通信息
                mssqlcmd.CommandText = "select * from h_Traffic where tParHouseId=" + oldid;

                DataSet Trafficset = new DataSet();
                mssqlda = new SqlDataAdapter(mssqlcmd);
                mssqlda.Fill(Trafficset);
                if (Trafficset.Tables[0].Rows.Count > 0)
                {
                    lp25 = "线路：" + Trafficset.Tables[0].Rows[0]["tCarCode"].ToString() + "  站点：" + Trafficset.Tables[0].Rows[0]["tCenter"].ToString();
                }
                string lp32 = mssqlset.Tables[0].Rows[i]["hMemo6"].ToString().Trim();//楼盘介绍
                string lp33 = mssqlset.Tables[0].Rows[i]["hMemo1"].ToString().Trim() + "<br/>" + mssqlset.Tables[0].Rows[i]["hMemo2"].ToString().Trim() + "<br/>" + mssqlset.Tables[0].Rows[i]["hMemo3"].ToString().Trim() + "<br/>" + mssqlset.Tables[0].Rows[i]["hMemo4"].ToString().Trim() + "<br/>" + mssqlset.Tables[0].Rows[i]["hMemo5"].ToString().Trim();//开发商介绍
                string lp34 = "";//业主小区
                string lp35 = "";//小区最新动态
                string lp36 = mssqlset.Tables[0].Rows[i]["YNumbrer"].ToString().Trim() + "," + mssqlset.Tables[0].Rows[i]["XNumbrer"].ToString().Trim();//百度地图坐标
                string lp37 ="";//视频展示
                string sum = mssqlset.Tables[0].Rows[i]["hCount"].ToString().Trim();//总户数
                if (sum == "")
                    sum = "0";
                string tag = mssqlset.Tables[0].Rows[i]["hType"].ToString().Trim();//标签
                string qishu = "";//在售期数
                string xingtai = "";//建筑形态
                if (type.Contains("多层"))
                    xingtai = "多层";
                if (type.Contains("高层"))
                    xingtai = "高层";
               
                string lougao = "";//楼高
                string dianti = "0";//电梯数
                string peizhi = "";//电梯配置
                string jingguan = mssqlset.Tables[0].Rows[i]["hDesgin2"].ToString().Trim();//景观设计
                string wuyefei = mssqlset.Tables[0].Rows[i]["hManageMoney"].ToString().Trim();//物业费
                string jiaotong = lp25;//交通配套
                string shenghuo = "超市："+lp24+"；银行："+lp26+"；医院："+lp27+"；餐厅："+lp28+"；健身："+lp29+"；其他："+lp30;//生活配套
                string jiaoyu = lp23;//教育配套
                string benqi = "";//本期房源
                string tixing = "";//提醒
              
              
               //插入图片

                string peitaotu = "有";//生活配套图
                string fuwu = "有";//社区服务概述
                string menjin = "有";//智能系统-电子门禁
                string baojing = "有";//智能系统-红外报警
                string jiankong = "有";//智能系统-监控系统
                string duijiang = "有";//智能系统-可视对讲
                string xunshi = "有";//智能系统-电子巡视
                string hujiao = "有";//智能系统-紧急呼叫
                string yangan = "有";//智能系统-烟感报警
                string cmdstr = string.Format(insertzhu, ids, typeid, flag, title, litpic, pubdate, senddate, keywords, lastpost, description, click);
                string fucmdstr = "INSERT INTO fdc_loupan (aid,typeid,userip,lp1,lp2,lp3,lp4,lp5,lp6,lp7,lp8,lp9,lp10,lp11,lp12,lp13,lp14,lp15,"+
                    "lp16,lp17,lp18,lp19,lp20,lp21,lp22,lp23,lp24,lp25,lp26,lp27,lp28,lp29,lp30,lp32,lp33,lp34,lp35,lp36,lp37,SUM,tag,qishu,xingtai"+
                    ",lougao,dianti,peizhi,jingguan,wuyefei,jiaotong,shenghuo,jiaoyu,benqi,tixing,huxing,peitaotu,fuwu,menjin,baojing,jiankong,duijiang,xunshi,hujiao,yangan)"
+ "VALUES ({0},106,'222.214.216.73','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}',{10},'{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}',{21},{22},'{23}','{24}','{25}','{26}','{27}','{28}','{29}','{30}','{31}','{32}','{33}','{34}','{35}','{36}',{37},'{38}','{39}','{40}','{41}','{42}','{43}','{44}','{45}','{46}','{47}','{48}','{49}','{50}','{51}','{52}','{53}','{54}','{55}','{56}','{57}','{58}','{59}','{60}')";
                string cmdstr2 = string.Format(fucmdstr, ids, lp1, lp2, lp3, lp4, lp5, lp6, lp7, lp8, lp9, lp10, lp11, lp12, lp13, lp14, lp15, lp16, lp17, lp18, lp19, lp20, lp21, lp22, lp23, lp24, lp25, lp26, lp27, lp28, lp29, lp30, lp32, lp33, lp34, lp35, lp36, lp37,sum,tag,qishu,xingtai,
                    lougao, dianti, peizhi, jingguan, wuyefei, jiaotong, shenghuo, jiaoyu, benqi, tixing, huxing, peitaotu, fuwu, menjin, baojing, jiankong, duijiang, xunshi, hujiao, yangan);
                mysqlcmd.CommandText = cmdstr;

                if (mysqlcmd.ExecuteNonQuery() > 0)
                {
                    mysqlcmd.CommandText = cmdstr2;
                    mysqlcmd.ExecuteNonQuery();
                }
                else
                {
                    MessageBox.Show(ids + "插入错误");
                }


            } mysqlcon.Close();
        }

    }
}
